-- || Created by Revelse

PlayerManager = inherit(Singleton)

addEvent("onPlayerVote", true)

function PlayerManager:constructor()
	addEventHandler("onPlayerJoin", root, bind(self.join,self))
	addEventHandler("onPlayerQuit", root, bind(self.quit,self))
	addEventHandler("onPlayerVote", root, bind(self.vote,self))
	addCommandHandler("leave", bind(self.leaveLobby,self))
end

function PlayerManager:vote(player)
	if not client then
		client = player
	end
	client:onVote()
end

function PlayerManager:leaveLobby(player)
	player:leaveLobby()
end

function PlayerManager:quit()
	delete(source)
end

function PlayerManager:join()
	source:join()
end

function PlayerManager:destructor()
	for key, value in ipairs(getElementsByType("player")) do
		delete(value)
	end
end